#!/bin/bash
#功能函数
funcs=`which functions.sh`
if [ "$funcs" != "" ] ;then
    . $funcs
else
    funcs=`dirname $0`/functions.sh
    echo "$PWD"
    echo "funcs=$funcs"
    if [ "$funcs" != "" ] ;then
	. $funcs
    else
	exit
    fi
fi

MINICOM=`which minicom`
if [ "$MINICOM" = "" ]; then
sudo apt-get install minicom
else
echo "minicom exist!"
fi

if [ "$1" = "" ]; then
    minicom=ttyUSB0
else
     minicom=$1
fi

echoColor "＊＊＊＊设置 minicom ＊＊＊" GREEN
cat >~/minirc.$minicom<<EOF
# Machine-generated file - use "minicom -s" to change parameters.
pu port             :  /dev/$minicom
EOF
echoText "配置文件为： /etc/minicom/minirc.$minicom" GREEN
sudo cp ~/minirc.$minicom  /etc/minicom/ -rf
rm ~/minirc.$minicom

result=`question "是否保存为默认？" 1 no`
if [  "$result" = "yes" ] ; then
    sudo cp /etc/minicom/minirc.$minicom /etc/minicom/minirc.dfl  -rvf
fi


